home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / Testing & Debugging / Virtual User tools / Memory Monitor 1.0.3 / MemoryMonitor Read Me.txt < prev    next >
Encoding:
Text File  |  1994-06-15  |  19.2 KB  |  422 lines  |  [TEXT/ttxt]

  1. Memory Monitor ReadMe
  2.  
  3.     This document describes Memory Monitor, a Virtual User 2.0 external tool which enables Virtual User script writers to get information about how memory is being utilized on a target Macintosh. Memory Monitor provides information from three different sources: the Process Manager, the Memory Manager, and Finder's "About This Macintosh" dialog.  If you are not familiar with Virtual User external tools, please refer to the “Using External Tools” chapter in the Virtual User Language Reference manual.
  4.  
  5. In This Package
  6.  
  7. The set of files for this Memory Monitor package includes:
  8. Memory Monitor Read Me    -    This file.
  9. Memory Monitor         -    The application which performs the services.
  10. MemoryMonitor.vu        -    A Virtual User example script.
  11. MemoryMonitor.vulib        -    A Virtual User task library which provides a task call interface.
  12. Apple® Event Manager 1.0.1    -    Bug fix extension for AppleEvents.
  13.  
  14. Memory Monitor Requirements
  15.  
  16. Hardware Requirements : 
  17.  
  18. Memory Monitor runs on all Macintosh models including and after the Macintosh Plus.
  19.  
  20. Software Requirements : 
  21.  
  22. Memory Monitor requires System Software 7.0 or greater, and Apple® Event Manager v1.0.1 or later. Memory Monitor requires Virtual User 2.0 or greater.
  23.  
  24. Installation
  25.  
  26. To install Memory Monitor on the Target: 
  27. Step 1: Copy the Memory Monitor application to a disk connected to the machine. 
  28.     The location of the application is not important to Virtual User.
  29. Step 2: Copy the Apple® Event Manager extension to the machine’s Extensions Folder.
  30.     ( In the future this extension may become obsolete, i.e. rolled into System Software ).
  31.  
  32. To install MemoryMonitor .vulib on the Host: 
  33. Step 1: On the host, drag the file “MemoryMonitor.vulib” to the same folder containing your other             Virtual User libraries.
  34.  
  35. General Memory Monitor Information
  36.  
  37.     The "MemoryMonitor.vulib" script library provides a task level interface for accessing the services provided by Memory Monitor. Script writers should use these tasks, rather than calling Memory Monitor directly, in order to localize all calls to Memory Monitor. In this way, if changes are ever made to the service level interface, the task level interface can remain the same, and required changes are isolated to one file.
  38.  
  39.     Each task in the library returns a list of four elements:  Error Code, Result, Error Message, Script Error Code. The first three elements, Error Code, Result, and Error Message, are the same as those returned from any external tool call ( see "Virtual User Language Reference" ). The fourth element, Script Error, is the value obtained from calling the built-in task ScriptError just after the tool call is made. In this way all information pertaining to the tool call is returned to the script.
  40.     
  41.     Several of the tasks either take as arguments or return numeric values which are larger than Virtual User supports ( supported range : -32768 … 32767 ). To get around this problem, all numeric values returned by Memory Monitor, which fall outside the supported range, are returned as numeric strings. The number 131072 would be returned as the string: '131072'. Numeric strings can be converted to regular numbers using the built-in task StrToNum().  If the number is too large to be converted, StrToNum() will return undefined.  You can still perform arithmetic operations or comparisons on these numeric strings, though, by using the MathTool, another external tool supplied with Virtual User.  (See the ReadMe documentation for the MathTool for more information.)
  42.  
  43.     Most tasks in the library take a boolean parameter called pCallAsync. This parameter determines if V.U. makes the tool call synchronously or asynchronously. If the call is made synchronously, the next statement of the V.U. script is not executed until the tool has completed it's operation and has returned a result. If the call is made asynchronously, script execution continues without waiting for the tool to complete its operation. The script must later "Poll" for the results. For a more thorough explanation see the Virtual User Language Reference. This parameter has a default value of false ( synchronous calls ), so if it is not specified in the parameter list a synchronous call is made.
  44.  
  45.  
  46. MemoryMonitor.vulib Tasks
  47.  
  48. InitMemoryMonitor
  49. Description
  50. InitMemoryMonitor task must be called before any other tasks within MemoryMonitor.vulib. It starts up Memory Monitor and makes it available to Virtual User.
  51. Syntax
  52. Task InitMemoryMonitor( LaunchOnTarget := false )
  53. Input
  54. The LaunchOnTarget is a Boolean parameter which determines whether Memory Monitor is launched on the target or the host. It is expected that most script writers will want to use Memory Monitor on the target, in which case they will pass a true expression. 
  55. Output
  56. The returned Result is not defined. In general it will be equal to the 'undefined' V.U. symbol.
  57. Diagnostics
  58. Any errors encountered are reported through Error Code, Error Message, and/or Script Error Code.
  59. Example
  60. Script Statements
  61.  
  62. x := InitMemoryMonitor( true );    #    Launch Memory Monitor on the target
  63. Println x;
  64.  
  65. Output ( reformatted with comments )
  66.  
  67. {    0,             # Error Code = 0, no error occured
  68.     undefined,         # Result , no additional info to return
  69.     undefined,         # Error Message , no error message
  70.     0             # Script Error, no script error occured
  71. }         
  72.  
  73.  
  74.  
  75. QuitMemoryMonitor
  76. Description
  77. QuitMemoryMonitor causes the Memory Monitor application to quit, and V.U. to no longer recognize Memory Monitor as an available external tool. If you call QuitMemoryMonitor ( say to free memory for other applications ), you must call InitMemoryMonitor again, before calling other MemoryMonitor.vulib tasks. 
  78. Syntax
  79. Task QuitMemoryMonitor( )
  80. Input
  81. There are no input parameters.
  82. Output
  83. The returned Result is not defined. In general it will be equal to the 'undefined' V.U. symbol.
  84. Diagnostics
  85. Any errors encountered are reported through Error Code, Error Message, and/or Script Error Code.
  86. Example
  87. Script Statements
  88.  
  89. x := QuitMemoryMonitor();    #    Quit the Memory Monitor application
  90. Println x;
  91.  
  92. Output ( reformatted with comments )
  93.  
  94. {    0,                 # Error Code = 0, no error occured
  95.     undefined,             # Result , no additional info to return
  96.     undefined,             # Error Message , no error message
  97.     0                 # Script Error, no script error occured
  98. }         
  99.  
  100.  
  101.  
  102. GetAllProcesses
  103. Description
  104. This task returns information about each Process Manager process. The information includes the following: name, type, signature, partition size, partition location in memory, free bytes within the partition, and the path name of the application.
  105. Syntax
  106. Task GetAllProcesses( CallAsync )…
  107. Input
  108. There are no input parameters for this task.
  109. Output
  110. The returned Result is a list containing one element for each process. Each element is a list that contains the following items: 
  111.  
  112. Index    Data Type    Data        Comments
  113. 1    string        Name        The process’ name
  114. 2    string        Type        The type of the process
  115. 3    string        Signature    The signature of the process
  116. 4    string        Size in bytes    Decimal digits of the size of the process’ partition
  117. 5    string        Location    Decimal digits of the starting address of the process’ partition
  118. 6    string        Free bytes    Decimal digits of the Free bytes in the process’ partition
  119. 7    string        Pathname    Full path name for the file from which the process originated
  120.  
  121. Diagnostics
  122. Any errors encountered are reported through Error Code, Error Message, and/or Script Error Code.
  123. Example
  124. Script Statements
  125.  
  126. ProcList := GetAllProcesses();
  127. Println ProcList;
  128.  
  129. Output ( reformatted with comments )
  130.  
  131. {    0,                    # call completed without errors
  132.     {                    # the list containing each process’ information
  133.         {         
  134.             'Finder',                 # Process Name
  135.             'APPL',                 # Type
  136.             'MACS',                 # Signature
  137.             '253664',                 # Size
  138.             '7436740',                 # Location
  139.             '5236',                 # Free Memory
  140.             'HD:System Folder:Finder'        # Free Memory
  141.         },    
  142.         ...                # More Processes, if existent
  143.     },    
  144.     undefined, 0
  145. }
  146.  
  147.  
  148. GetProcessInfo
  149. Description
  150. This task returns information about a specific Process Manager process. The information includes the following: name, type, signature, partition size, partition location in memory, free bytes within the partition, and the pathname to the application. This task is essentially the same as GetAllProcesses, but it returns information pertaining to only the specified process.
  151. Syntax
  152. Task GetProcessInfo( procName, CallAsync )…
  153. Input
  154. The procName parameter is the name of the process for which information is to be gathered.
  155. Output
  156. The returned Result is a list and contains the following items: 
  157.  
  158. Index    Data Type    Data        Comments
  159. 1    string        Name        The process’ name
  160. 2    string        Type        The type of the process
  161. 3    string        Signature    The signature of the process
  162. 4    string        Size in bytes    Decimal digits of the size of the process’ partition
  163. 5    string        Location    Decimal digits of the starting address of the process’ partition
  164. 6    string        Free bytes    Decimal digits of the Free bytes in the process’ partition
  165. 7    string        Pathname    Full path name for the file from which the process originated
  166.  
  167. Diagnostics
  168. Any errors encountered are reported through Error Code, Error Message, and/or Script Error Code.
  169. Example
  170. Script Statements
  171.  
  172. ProcInfo := GetProcessesInfo( 'Finder' );
  173. Println ProcInfo;
  174.  
  175. Output ( reformatted with comments )
  176.  
  177. {    0,                        # call completed without errors
  178.     {         
  179.         'Finder',                 # Process Name
  180.         'APPL',                 # Type
  181.         'MACS',                 # Signature
  182.         '253664',                 # Size
  183.         '7436740',                 # Location
  184.         '5236',                 # Free Memory
  185.         'HD:System Folder:Finder'         # Free Memory
  186.     },    
  187.     undefined,                    # no error message
  188.     0                        # no script error occurred
  189. }
  190.  
  191.  
  192. GetZoneTotals
  193. Description
  194. This task returns a summary of how memory is being utilized within a specific heap zone. There are three major categories: Free blocks, Nonrelocatable blocks, and Relocatable blocks. The third category is further broken down into two minor categories: Locked Relocatable and Purgable & Unlocked Relocatable. For each category the number of blocks allocated and the total bytes which they occupy is reported.
  195. Syntax
  196. Task GetZoneTotals( ZoneSelector, pCallAsync := false )
  197. Input
  198. The ZoneSelector parameter determines which heap zone is examined. There are two forms, one for top level heap zones, and one for nested heap zones. 
  199.  
  200. Form 1: This is the simplest form, consisting of a single string. The string contains the name of a Process Manager process. The heap zone belonging to that process is examined. Example: 'Finder' - the Finder's heap zone.
  201.  
  202. Form 2: This is the more complex form, consisting of a list whose first item is a process name ( like form 1 ) and following items are integers. The string contains a Process Manager process name. The following integers are interpreted as indecies for the nested heap zones. The indecies are assigned according to the order within the memory address space. Example: { 'Memory Monitor', 2 } - the second nested zone within Memory Monitor's heap zone.
  203.  
  204. Two special names have been defined for the heap zones which don't belong to a Process Manager process, that is the System heap zone and the MultiFinder (or Process Manager ) heap zone. The two names are 'SystemZone' and 'MultiFinderZone'. These names may be used in place of a process name in either forms above. 
  205. Example { 'SystemZone', 2, 1 } - the first nested heap zone within the second nested heap zone within the System heap zone.
  206. Output
  207. The returned Result is a list of six elements which contain the number of blocks and the total bytes within those blocks for each of the five categories ( Free, Nonrelocatable, Relocatable, Locked Relocatable, Purgable Relocatable) and the over all total. The list looks like this:
  208.  
  209. Index    Data Type    Data                Comments
  210. 1    list        Free                Free space
  211. 2    list        Nonrelocatable            Nonrelocatable space
  212. 3    list        Relocatable            Relocatable space
  213. 4    list        Locked                Locked Relocatable space
  214. 5    list        Unlocked & Purgable        Unlocked & Purgable Relocatable
  215. 6    list        Total                Over all
  216.  
  217. Each of the six elements contains a list of two numbers: the number of blocks in that category, and the total number of bytes occupied by those blocks. The list looks like this:
  218.  
  219. Index    Data Type    Data                Comments
  220. 1    number    Block Count            The number of blocks
  221. 2    string        Byte Count            Decimal digits of the byte count
  222. Diagnostics
  223. Any errors encountered are reported through Error Code, Error Message, and/or Script Error Code.
  224. Example
  225. Script Statements
  226.  
  227. ZTotals := GetZoneTotals();
  228. Println ZTotals;
  229.  
  230. Output ( reformatted with comments )
  231.  
  232. {    0,                    # call completed without errors
  233.     {    {    16,  '512720' },    # Free             : blocks, bytes
  234.         {    39,   '58304' },    # Nonrelocatable         : blocks, bytes
  235.         {  1182,  '655856' },    # Relocatable         : blocks, bytes
  236.         {    64,  '400256' },    # Locked            : blocks, bytes
  237.         {    31,   '58624' },    # Purgable & Unlocked     : blocks, bytes
  238.         { 12337, '1226880' },    # Over all total        : blocks, bytes
  239.     }, undefined, 0                
  240. }
  241.  
  242.  
  243. GetZoneMap
  244. Description
  245. This task returns a list of information indicating the location and size of a specified heap zone and all nested sub-zones.
  246. Syntax
  247. Task GetZoneMap( ZoneSelector, pCallAsync := false )
  248. Input
  249. The ZoneSelector parameter is the same that is used by GetZoneTotals. Please refer to the Input section under GetZoneTotals for more information. The CallAsync parameter determines if the call is made asynchronously or synchronously.
  250. Output
  251. The returned Result is a list containing one element for each heap zone. Each element is a list and contains the following items: 
  252.  
  253. Index    Data Type    Data            Comments
  254. 1    string        Starting Address    Decimal digits of the heap zone's starting address
  255. 2    string        Ending Address    Decimal digits of the heap zone's ending address
  256. 3    string        Size in bytes        Decimal digits of the heap zone's size in bytes
  257. 4    list        List of nested zones    A list containing information about any nested zones
  258.                         if there are no nested zones, the list has zero elements.
  259. Diagnostics
  260. Any errors encountered are reported through Error Code, Error Message, and/or Script Error Code.
  261. Example
  262. Script Statements
  263.  
  264. ZoneList := GetZoneMap( 'SystemZone' );
  265. Println ZoneList;
  266.  
  267. Output ( reformatted with comments )
  268.  
  269. {    0,                        # call completed without errors
  270.     {                        # First Non-nested zone (System Zone)
  271.         { '8192','1294903','1286711',    # Start, End, Size
  272.            {     
  273.             { '8632','9891','1259',{} },        # First nested zone
  274.             { '520460','530699','10239',{} }    # Second nested zone
  275.            } 
  276.         }
  277.     }, 
  278.     undefined,                    # no error message
  279.     0                        # no script error occurred
  280. }
  281.  
  282.  
  283. CheckZone
  284. Description
  285. This task simply scans the zone and reports if any corrupted Memory Manager data structures are detected. Not all types of data corruptions are detected, but those that are detected are reported. The task returns a true  if no corruptions are found, and false if a corruption is detected. 
  286. Syntax
  287. Task CheckZone( ZoneSelector, pCallAsync := false  )
  288. Input
  289. The ZoneSelector parameter is the same that is used by GetZoneTotals. Please refer to the Input section under GetZoneTotals for more information. The CallAsync parameter determines if the call is made asynchronously or synchronously.
  290. Output
  291. The returned Result is a boolean value. True for no corruptions detected, False when a corruption is detected.
  292. Diagnostics
  293. Any errors encountered are reported through Error Code, Error Message, and/or Script Error Code.
  294. Example
  295. This example checks the System heap for memory corruptions
  296.  
  297. Script Statements
  298.  
  299. HeapCheckResult := CheckZone( 'SystemZone' );
  300. Println HeapCheckResult;
  301.  
  302. Output ( reformatted with comments )
  303.  
  304. { 0, true, undefined, 0 } # No errors, Heap is ok, no error message, no script error
  305.  
  306.  
  307. GetAboutThisMacintosh
  308. Description
  309. This task returns information which is available to the user via the "About This Macintosh" dialog. 
  310. Syntax
  311. Task GetAboutThisMacintosh( pCallAsync := false )
  312. Input
  313. The CallAsync parameter determines if the call is made asynchronously or synchronously.
  314. Output
  315. The returned Result is a list containing one element for each heap zone. Each element is a list and contains the following items: 
  316.  
  317. Index    Data Type    Data                Comments
  318. 1    string        Physical Memory        Decimal digits of the Physical memory in kilobytes
  319. 2    string        Logical Memory        Decimal digits of the Logical memory in kilobytes
  320. 3    string        Largest Free Block        Decimal digits of the largest free block in kilobytes
  321. 4    list        List of application info        A list containing information for each application
  322.  
  323. For each Application the following information is returned.
  324. Index    Data Type    Data            Comments
  325. 1    string        Name            The name of the application in bytes
  326. 2    string        Memory usage        Decimal digits of the application's partition size in bytes
  327. Diagnostics
  328. Any errors encountered are reported through Error Code, Error Message, and/or Script Error Code.
  329. Example
  330. Script Statements
  331.  
  332. AboutThisMacInfo := GetAboutThisMacintosh();
  333. Println AboutThisMacInfo;
  334.  
  335. Output ( reformatted with comments )
  336.  
  337. {    0,                # call completed without errors
  338.     {     
  339.         '8192',        # Physical Memory
  340.         '8191',        # Logical Memory
  341.         '1977',        # Largest unused block
  342.         { 
  343.             { 'System',          '318464' },    # Name, Partition Size
  344.             { 'SurfWriter',      '2064384' },    # Name, Partition Size
  345.             { 'Memory Monitor', '272384' }    # Name, Partition Size
  346.         }
  347.     },
  348.     undefined,            # no error message
  349.     0                # no script error occurred
  350. }
  351.  
  352.  
  353. ReadBytes
  354. Description
  355. This task "Reads" bytes from the specified location in memory and returns them to the script. This task can be used to get "Raw" data from any location in memory.
  356. Syntax
  357. Task ReadBytes( StartingAddress, ByteCount , pCallAsync := false )
  358. Input
  359. The StartingAddress parameter is the address of the first byte to read. ByteCount indicates the number of bytes to read. CallAsync determines if the call is made asynchronously or synchronously.
  360. Output
  361. The task's result is a list of numbers, each representing one of the bytes read.
  362. Diagnostics
  363. Any errors encountered are reported through Error Code, Error Message, and/or Script Error Code.
  364. Example
  365. This example reads the low global containing the current application's name.
  366. Script Statements
  367.  
  368. ### Fetch the bytes of interest
  369. AppName := ReadBytes( { 0, 2320 }, 32 );    
  370.  
  371. ### Convert the list of bytes to a character string
  372. s := "";
  373. for i := 2 to AppName[2][1] + 1
  374.     s := s + CodeToCharacter( AppName[2][i] );
  375.  
  376. ### Print the string
  377. Println "App Name = '", s, "'";
  378.  
  379. Output ( reformatted with comments )
  380.  
  381. App Name = 'Memory Monitor'
  382.  
  383.  
  384. MacsBugCmd
  385. Description
  386. This task allows the script to execute Macsbug commands via the Macsbug command line. Make sure that Macsbug is installed before using this service.
  387. Syntax
  388. Task MacsbugCmd(    CommandLine, 
  389.             Label := "Memory Monitor", 
  390.             RemainInMacsBug := false, 
  391.             pCallAsync := false )
  392.  
  393. Input
  394. The CommandLine parameter contains the command line to be executed by Macsbug. One or more commands can be given, but multiple commands must be separated by semi-colons.
  395.  
  396. The Label parameter specifies the message which will appear in the Macsbug display. The default value is 'Memory Monitor'.
  397.  
  398. The RemainInMacsbug parameter is provided in case the scriptor wants to remain in Macsbug. Passing a value of 'true' will prevent the appending of a "Go" command to the command line.
  399.  
  400. CallAsync determines if the call is made asynchronously or synchronously.
  401. Output
  402. The returned Result is true if executed successfully, otherwise it is undefined. 
  403. Diagnostics
  404. Any errors encountered are reported through Error Code, Error Message, and/or Script Error Code.
  405. Example
  406. This example logs some info into a log file using Macsbug.
  407. Script Statements:
  408.  
  409. ###    Open a log file named "ExampleLog", 
  410. ###    do a HT (Heap Total) command 
  411. ###    close the log and exit Macsbug
  412.  
  413. Result := MacsbugCmd( "log TempFile; HT; log;" );    
  414.  
  415. ### Print the Result
  416. Println Result;
  417.  
  418. Output ( reformatted with comments )
  419.  
  420. { 0, true, undefined, 0 }     # No errors, Executed Ok, 
  421.                     # no error message, no script error
  422.